#ifndef MOTOR_CONTROL_H_
#define MOTOR_CONTROL_H_

#include "pwm.h"
#include "magnetic_encoder.h"

class MotorControl
{
  public:
    MotorControl(void);

    void updatePhase(void);
    void setDutyCycle(int duty_cycle);
    void setPhaseOffset(int phase_offset);
    int getPhaseIndex(void) const;
    int getAngle(void) const;
    void updateAngleMeasurement(int pi);
  
  private:
    Pwm *pwm;
    MagneticEncoder *magnetic_encoder;
  
    int angle;
    int old_phase_index;
    int phase_delta;
    int duty_cycle;     // -99 - 99
    int old_duty_cycle;
    int phase_offset;
};

#endif /* MOTOR_CONTROL_H_ */
